//index.js
//获取应用实例
const app = getApp();
let localMap = new Map();// 定义一个全局的MAP对象 
localMap.set("collect", "collect");
localMap.set("bug", "bug");
localMap.set("report", "report");
localMap.set("practice", "practice");
Page({
  data: {
    grids: [0, 1, 2, 3, 4],
    imgUrls: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    navList: [
      {
        name: "我的收藏",
        url: "/images/tabicon/collect.png",
        flag: "collect"
      },
      {
        name: "错题练习",
        url: "/images/tabicon/bug.png",
        flag: "bug"
      },

      {
        name: "每日一练",
        url: "/images/tabicon/practice.png",
        flag: "practice"
      },
      {
        name: "答题报告",
        url: "/images/tabicon/report.png",
        flag: "report"
      },
    ],
    recommend: [0, 1, 2],
    bookList: [],
    indicatorDots: true,   // 是否显示轮播指示点
    autoplay: true,        // 是否自动播放轮播
    interval: 5000,         // 轮播间隔
    duration: 1000,         // 轮播播放延迟
    circular: true,         // 是否采用衔接滑动
    sideMargin: '100rpx',   // 幻灯片前后边距
    showLoading: true       // 是否显示loading态
  },
  changeIndicatorDots: function (e) {
    this.setData({
      indicatorDots: !this.data.indicatorDots
    })
  },
  changeAutoplay: function (e) {
    this.setData({
      autoplay: !this.data.autoplay
    })
  },
  intervalChange: function (e) {
    this.setData({
      interval: e.detail.value
    })
  },
  durationChange: function (e) {
    this.setData({
      duration: e.detail.value
    })
  },
	//根据定义的全局map取值，跳转对应的页面 导航栏处
	goPageByKey: function (e) {
    console.log(e);
    console.log(localMap);
    var flag = e.currentTarget.dataset.flag;
    var url;
    if (localMap.get(flag)) {
      url = "../" + localMap.get(flag) + "/" + localMap.get(flag) + "";
    }
    wx.navigateTo({
      url: url
    })
  }

})
